package com.link.base.base.orgnization;

import com.link.base.base.orgnization.service.OrgnizationService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.model.CallParam;
import com.link.core.basic.service.ServiceException;
import com.link.core.util.BeanTools;
import com.link.core.util.RedisUtil;
import com.link.core.util.redisclient.LinkRedisClient;


/**
 * desc  更新组织架构的异步线程实现
 *
 * @author libo
 * @date   2019-07-11
 * @param
 */
public class UpdateOrganization implements Runnable {
    private CallParam callParams;
    String redisKey = "";

    /**
     * desc   线程里面接受参数
     *
     * @author libo
     * @date   2019-07-12
     * @param  callParam 参数实体保存帐套等信息， key:redis中设置的正在更新组织的标记key
     */
    public UpdateOrganization(CallParam callParam, String key) {
        this.callParams = callParam;
        this.redisKey = key;
    }

    @Override
    public void run() {
        LinkRedisClient jedis = null;
        try {
            jedis = RedisUtil.getJedis();
            OrgnizationService orgnizationService =  (OrgnizationService) BeanTools.getBean(OrgnizationService.class);
            orgnizationService.getRunOrgUpdateNoCall(callParams);
            jedis.del(redisKey);
        } catch (Exception e) {
            LCLogger.withException(e);
            throw new ServiceException("ORGNIZATION-002");
        }
    }
}
